package jd.client;

import java.io.IOException;
import java.util.List;

import jd.client.exception.ResponseParseException;
import jd.client.help.HelpResponse;
import jd.entity.Config;
import jd.entity.DownloadPackage;

/**
 * @author Denis Migol
 * 
 */
public interface JDClient {

	public static final String DEFAULT_HOST = "127.0.0.1";
	public static final int DEFAULT_PORT = 10025;

	/**
	 * @return the host
	 */
	public abstract String getHost();

	/**
	 * @return the port
	 */
	public abstract int getPort();

	/**
	 * 
	 * @param request
	 * @return
	 * @throws GetResponseParseException
	 * @throws IOException
	 */
	public abstract Response execute(final Request request) throws ResponseParseException, IOException;

	/**
	 * 
	 * @param request
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract Response execute(final String request) throws ResponseParseException, IOException;

	/**
	 * 
	 * @return
	 * @throws GetResponseParseException
	 * @throws IOException
	 */
	public abstract HelpResponse help() throws ResponseParseException, IOException;

	/**
	 * Get current Speed
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String getSpeed() throws ResponseParseException, IOException;

	/**
	 * Get IP
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String getIP() throws ResponseParseException, IOException;

	/**
	 * Answers with Random IP as replacement for real IP-Check
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String getRandomIP() throws ResponseParseException, IOException;

	/**
	 * Get Config
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract Config getConfig() throws ResponseParseException, IOException;

	/**
	 * Get Version
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String getVersion() throws ResponseParseException, IOException;

	/**
	 * Get RemoteControl Version
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String getRCVersion() throws ResponseParseException, IOException;

	/**
	 * Get current Speedlimit
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String getSpeedLimit() throws ResponseParseException, IOException;

	/**
	 * Get If Reconnect
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract Boolean getIsReconnect() throws ResponseParseException, IOException;

	/**
	 * Get Download status
	 * <p>
	 * Values: RUNNING, NOT_RUNNING, STOPPING
	 * <p>
	 * TODO
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract Integer getDownloadStatus() throws ResponseParseException, IOException;

	/**
	 * Get amount of current downloads
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract Integer getDownloadsCurrentCount() throws ResponseParseException, IOException;

	/**
	 * Get Current Downloads List (XML)
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract List<DownloadPackage> getDownloadsCurrentList() throws ResponseParseException, IOException;

	/**
	 * Get amount of downloads in list
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract Integer getDownloadsAllCount() throws ResponseParseException, IOException;

	/**
	 * Get list of downloads in list (XML)
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract List<DownloadPackage> getDownloadsAllList() throws ResponseParseException, IOException;

	/**
	 * Get amount of finished Downloads
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract Integer getDownloadsFinishedCount() throws ResponseParseException, IOException;

	/**
	 * Get finished Downloads List (XML)
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract List<DownloadPackage> getDownloadsFinishedList() throws ResponseParseException, IOException;

	/**
	 * Start DLs
	 */
	public abstract String actionStart() throws ResponseParseException, IOException;

	/**
	 * Pause DLs
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String actionPause() throws ResponseParseException, IOException;

	/**
	 * Stop DLs
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String actionStop() throws ResponseParseException, IOException;

	/**
	 * Toggle DLs
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String actionToggle() throws ResponseParseException, IOException;

	/**
	 * Do Webupdate
	 * 
	 * @param force
	 *            activates auto-restart if update is possible
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String actionUpdate(final boolean force) throws ResponseParseException, IOException;

	/**
	 * Do Reconnect
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String actionReconnect() throws ResponseParseException, IOException;

	/**
	 * Restart JD
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String actionRestart() throws ResponseParseException, IOException;

	/**
	 * Shutdown JD
	 * 
	 * @return
	 * @throws ResponseParseException
	 * @throws IOException
	 */
	public abstract String actionShutdown() throws ResponseParseException, IOException;

	public abstract void actionSetDownloadLimit();

	public abstract void actionSetDownloadMax();

	/**
	 * Add Links to Grabber
	 * 
	 * @param grabber
	 *            Hide(false)/Show(true) LinkGrabber
	 * @param start
	 *            start(true)/don't start(false) downloads afterwards
	 * @param links
	 * @return
	 * @throws Exception
	 */
	public abstract String actionAddLinksGrabber(final boolean grabber, final boolean start, final List<String> links)
			throws Exception;

	public abstract void actionAddContainerGrabber();

	public abstract void actionSaveContainer();

	public abstract void actionSetReconnectEnabled(final boolean enabled);

	public abstract void actionSetPremiumEnabled(final boolean enabled);

}